﻿using Microsoft.AspNetCore.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SignalRvideo
{
    public class WebSignalHub:Hub
    {
        public WebSignalHub()
        {

        }

        public void SendMessage(string user, string message)
        {
            Console.WriteLine("User {0} come {1}", user, message);
        }

        public void SwitchVideo(string user,int option)
        {
            Console.WriteLine("User {0} swicth video", user);
            CvWorker.SwitchVideo(option);
        }

        public override Task OnConnectedAsync()
        {
            CvWorker.SetToWork();
            return base.OnConnectedAsync();
        }


        public override Task OnDisconnectedAsync(Exception exception)
        {
            CvWorker.SetIdle();
            return base.OnDisconnectedAsync(exception);
        }
    }
}
